#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod1 998244353
#define mod2 1000000007
#define pb push_back
#define ppb pop_back
#define FILENAME "detect"
inline ll read(){
    ll x=0,f=1;
    char ch=getchar();
    while(ch>'9'||ch<'0'){
        if(ch=='-')f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    return x*f;
}
void print(ll x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9)print(x/10);
    putchar(x%10+'0');
}
ll fac[100005],inv[100005],mod=mod1;
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll fastpow(ll base,ll p){
    if(p==0)return 1ll;
    if(p==1)return base;
    if(p%2)return fastpow(base*base%mod,p/2)*base%mod;
    else return fastpow(base*base%mod,p/2);
}
void init(ll n){
    fac[0]=inv[0]=1;
    for(int i=1;i<=n;i++)fac[i]=fac[i-1]*i%mod;
    inv[n]=fastpow(fac[n],mod-2);
    for(int i=n-1;i>=1;i--)inv[i]=inv[i+1]*(i+1)%mod;
}
ll C(ll n,ll m){return fac[n]*inv[m]%mod*inv[n-m]%mod;}

ll fa[100005];
ll find(ll x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void unite(ll x,ll y){fa[find(x)]=find(y);}

ll lowbit(ll x){return x&-x;}
ll t,n,m,len,vv,cnt,vis[100005],d[100005],v[100005],a[100005],p[100005];
pll pr[100005];
ll work(ll x){
    ll tl=1,tr=m,mid,res=m;
    while(tl<=tr){
        mid=(tl+tr)/2;
        if(p[mid]>=x){
            res=mid;
            tr=mid-1;
        }
        else tl=mid+1;
    }
    return res;
}
void solve(){
    cnt=0;
    cin>>n>>m>>len>>vv;
    for(int i=1;i<=n;i++)cin>>d[i]>>v[i]>>a[i];
    for(int i=1;i<=m;i++)cin>>p[i];
    for(int i=1;i<=n;i++){
        if(d[i]>p[m])continue;
        else if(a[i]<0&&v[i]<=vv)continue;
        else if(a[i]==0&&v[i]<=vv)continue;
        else if(a[i]==0){
            pr[++cnt].fi=m;
            pr[cnt].se=work(d[i]);
        }
        else if(a[i]>0&&v[i]>vv){
            pr[++cnt].fi=m;
            pr[cnt].se=work(d[i]);
        }        
        else if(a[i]<0){
            ll x=v[i]*v[i]-vv*vv,y=a[i]*(-2),nl=work(d[i]),nr;
            ll nd=(x+y-1)/y+d[i];
            if(nd>p[m])nr=m;
            else nr=work(nd)-1;
            if(nr<nl)continue;
            pr[++cnt].se=nl;
            pr[cnt].fi=nr;
        }
        else{
            ll x=vv*vv-v[i]*v[i],y=a[i]*2,nr=m,nl;
            ll nd=x/y+d[i]+1;
            if(nd>p[m])continue;
            nl=work(nd);
            pr[++cnt].se=nl;
            pr[cnt].fi=nr;
        }
    }
    cout<<cnt<<" ";
    sort(pr+1,pr+cnt+1);
    p[0]=-1;
    ll ans=0,now=0;
    for(int i=1;i<=cnt;i++){
        if(now<pr[i].se){
            now=pr[i].fi;
            ans++;
        }
    }
    cout<<m-ans<<"\n";
    return;
}
int main(){
    freopen(FILENAME ".in","r",stdin);
    freopen(FILENAME ".out","w",stdout);
    cin>>t;
    while(t--)solve();
    return 0;
}